home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
051-075
/
disk_066
/
nart
/
rnd.s
< prev
next >
Wrap
Text File
|
1992-05-06
|
798b
|
45 lines
*\
* :ts=8 bk=0
* Yet Another random number generator. By Leo Schwab.
* Based on an idea posted on the USENET (Thanks, Sam Dicker!)
* For the MetaComCo assembler
*
* Calling convention:
* long rnd (range);
* long range;
*
* Assembling:
* df1:c/assem rnd.s -o rnd.o
*
* 8606.30
*/
section code
xdef _rnd
_rnd lea rndseed,a0 Get address of seed
move.l 4(sp),d1 Get range argument
tst.l d1
ble.s setseed Go reset seed
move.l (a0),d0 Get seed
ADD.L D0,D0
BHI.S over
EORI.L #$1D872B41,D0
over
move.l d0,(a0) Save new seed
andi.l #$ffff,d0 Coerce into word
andi.l #$ffff,d1
divu d1,d0 Divide by range
swap d0 and get remainder (modulus)
ext.l d0
rts
setseed neg.l d1 Probably don't need this
move.l d1,(a0)
rts
section data
rndseed dc.l 0